(require 'org-protocol)

;; Org-Reference
(require 'org-ref)
(setq reftex-default-bibliography "~/Nextcloud/Org/ref/library.bib"
           org-ref-default-bibliography '("~/Nextcloud/Org/ref/library.bib")
           org-ref-bibliography-notes "~/Nextcloud/Org/ref/notes/bibnotes.org"
           org-ref-pdf-directory "~/Nextcloud/Org/ref/pdf/")

;; Org-Roam
(add-hook 'after-init-hook 'org-roam-mode)
(setq  org-roam-directory "~/Nextcloud/Org/org-roam/"
       org-roam-db-location "~/Nextcloud/Org/org-roam/org-roam.db")
(setq org-roam-buffer-position 'right
      org-roam-buffer-width 0.3
      org-roam-verbose nil
      org-roam-buffer-window-parameters '((no-delete-other-windows . t))
      org-roam-completion-system 'helm)
 (setq org-roam-capture-templates
           '(("d" "default" plain #'org-roam--capture-get-point
              "%?"
              :file-name "%(format-time-string \"%Y-%m-%d--%H-%M-%SZ--${slug}\" (current-time) t)"
              :head "#+TITLE:${title}\n#+ROAM_TAGS: \n\n- TAGS :: " 
              :unnarrowed t)))
(rx/global-set-keys
 "C-c n l" 'org-roam
 "C-c n f" 'org-roam-find-file
 "C-c n i" 'org-roam-insert
 "C-c n I" 'org-roam-insert-immediate)

;; Deft
(rx/global-set-keys "<f8>" 'deft)
(setq deft-directory "~/Nextcloud/Org/org-roam/"
      deft-default-extension "org"
      deft-extensions '("org" "md")
      deft-use-filename-as-title nil
      deft-use-filter-string-for-filename t
      deft-auto-save-interval -1.0)

(setq deft-file-naming-rules
      '((noslash . "-")
        (nospace . "-")
        (case-fn . downcase)))

(provide 'init-notes)
